package com.roger.springcloudGreenwich.oauth.controller;

import net.jodah.expiringmap.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@ControllerAdvice
@RestController
@RequestMapping("/api/role")
public class TestController {

    /**
     * @return
     */
    @GetMapping("/")
    public String test() {
        return "success";
    }

    public static void main(String[] args) throws InterruptedException {
        ExpiringMap<String,String> map = ExpiringMap.builder()
                .maxSize(1000)
                .expiration(1, TimeUnit.SECONDS)
                .expirationPolicy(ExpirationPolicy.ACCESSED)
                .variableExpiration()
                .build();
        map.put("test","test123");
        Thread.sleep(5000);
        String test= map.get("test");
        System.err.println(test);
    }
}
